<!DOCTYPE html>
<html><!-- index for ws.js or totally online Web IDE -->
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=1280, initial-scale=1, maximum-scale=1"/>
  <meta name="apple-mobile-web-app-capable" content="yes"/>
  <meta name="mobile-web-app-capable" content="yes"/>
  <meta name=apple-mobile-web-app-status-bar-style content="black">

  <link rel="icon" href="favicon.ico">

  <link href="css/ui-lightness/jquery-ui-1.10.1.custom.css" rel="stylesheet">
  <link href="css/reset.css" rel="stylesheet" media="all"></link>
  <link href="css/main.css" rel="stylesheet" media="all"></link>
  <link href="css/typography.css" rel="stylesheet" media="all"></link>
  <link href="css/abstracts.css" rel="stylesheet" media="all"></link>
  <link href="css/components.css" rel="stylesheet" media="all"></link>
  <link href="css/icons.css" rel="stylesheet" media="all"></link>

  <link rel="stylesheet" href="js/libs/codemirror/css/codemirror.css">
  <link rel="stylesheet" href="css/libs/jquery.treeview.css"></link>
  <link rel="stylesheet" href="js/libs/codemirror/addon/lint/lint.css">
  <link rel="stylesheet" href="js/libs/codemirror/addon/hint/show-hint.css">
  <link rel="stylesheet" href="js/libs/codemirror/addon/dialog/dialog.css">
  <link rel="stylesheet" href="js/libs/codemirror/addon/fold/foldgutter.css" />
  <link rel="stylesheet" href="js/libs/codemirror/addon/tern/tern.css" />
  <link rel="stylesheet" href="js/libs/splitster/splitster.css" />
  <link rel="stylesheet" href="js/libs/toastr/toastr.css" />
  <link rel="stylesheet" href="js/libs/guiders/guiders.css" />

  <script>
    // Force HTTPS - needed for web bluetooth
    var l = window.location.toString();
    if (l.substr(0,7)=="http://" && !window.location.port)
      window.location = "https://"+l.substr(7);
  </script>

  <script src="js/libs/jquery-1.11.0.js"></script>
  <script src="js/libs/jquery-ui-1.10.1.custom.js"></script>
  <script src="js/libs/jquery.treeview.js"></script>
  <script src="js/libs/jquery.sparkline.min.js"></script>
  <script src="js/libs/splitster/splitster.js"></script>
  <script src="js/libs/toastr/toastr.min.js"></script>
  <script src="js/libs/guiders/guiders.js"></script>
  <script src="js/libs/flot/jquery.flot.js"></script>
  <script src="js/libs/flot/jquery.flot.time.js"></script>
  <script src="js/libs/jcanvas/jcanvas.min.js"></script>

  <script src="js/libs/codemirror/codemirror.js"></script>
  <script src="js/libs/codemirror/codemirror-javascript.js"></script>
  <script src="js/libs/codemirror/addon/dialog/dialog.js"></script>
  <script src="js/libs/codemirror/addon/hint/show-hint.js"></script>
  <script src="js/libs/codemirror/addon/fold/foldcode.js"></script>
  <script src="js/libs/codemirror/addon/fold/foldgutter.js"></script>
  <script src="js/libs/codemirror/addon/fold/brace-fold.js"></script>
  <script src="js/libs/codemirror/addon/fold/comment-fold.js"></script>
  <script src="js/libs/codemirror/addon/tern/tern.js"></script>
  <script src="js/libs/codemirror/addon/edit/closebrackets.js"></script>
  <script src="js/libs/codemirror/addon/search/searchcursor.js"></script>
  <script src="js/libs/codemirror/addon/search/match-highlighter.js"></script>
  <script src="js/libs/codemirror/addon/jshint/jshint.js"></script>
  <script src="js/libs/codemirror/addon/lint/lint.js"></script>
  <script src="js/libs/codemirror/addon/lint/javascript-lint.js"></script>
  <script src="js/libs/codemirror/addon/edit/trailingspace.js"></script>
  <script src="js/libs/codemirror/addon/search/searchcursor.js"></script>
  <script src="js/libs/codemirror/addon/search/search.js"></script>

<script src="js/libs/acorn/acorn.js"></script>
<script src="js/libs/acorn/acorn_loose.js"></script>
<script src="js/libs/acorn/walk.js"></script>
<script src="js/libs/acorn/signal.js"></script>
<script src="js/libs/acorn/tern.js"></script>
<script src="js/libs/acorn/def.js"></script>
<script src="js/libs/acorn/comment.js"></script>
<script src="js/libs/acorn/infer.js"></script>
<script src="js/libs/acorn/doc_comment.js"></script>

  <script src="EspruinoTools/espruino.js"></script>

  <script src="EspruinoTools/core/utils.js"></script>
  <script src="EspruinoTools/core/config.js"></script>
  <script src="js/core/html.js"></script>
  <script src="js/core/notifications.js"></script>
  <script src="js/core/status.js"></script>
  <script src="js/core/app.js"></script>

  <script src="EspruinoTools/core/serial.js"></script>
  <script src="EspruinoTools/core/serial_chrome.js"></script>
  <script src="EspruinoTools/core/serial_audio.js"></script>
  <script src="EspruinoTools/core/serial_socket.js"></script>
  <script src="EspruinoTools/core/serial_nodeserial.js"></script>
  <script src="EspruinoTools/core/serial_web_bluetooth.js"></script>
  <script src="EspruinoTools/core/terminal.js"></script>
  <script src="EspruinoTools/core/codeWriter.js"></script>
  <script src="EspruinoTools/core/modules.js"></script>
  <script src="EspruinoTools/core/env.js"></script>
  <script src="EspruinoTools/core/flasher.js"></script>

  <script src="js/core/editorBlockly.js"></script>

  <!-- Popup Windows -->
  <script src="js/core/menuPortSelector.js"></script>
<!--  <script src="js/core/menuSettings.js"></script> -->

  <!-- Non-vital Plugins -->
  <script src="EspruinoTools/plugins/boardJSON.js"></script>
  <script src="EspruinoTools/plugins/versionChecker.js"></script>
  <script src="EspruinoTools/plugins/compiler.js"></script>
  <script src="EspruinoTools/plugins/assembler.js"></script>
  <script src="EspruinoTools/plugins/getGitHub.js"></script>
  <script src="EspruinoTools/libs/utf8.js"></script> <!-- needed for unicode -->
  <script src="EspruinoTools/plugins/unicode.js"></script>
  <script src="EspruinoTools/plugins/saveOnSend.js"></script>
  <script src="EspruinoTools/plugins/setTime.js"></script> <!-- This should come after save on send -->

  <script src="EspruinoTools/libs/esprima/esprima.js"></script> <!-- needed for minify -->
  <script src="EspruinoTools/libs/esprima/esmangle.js"></script> <!-- needed for minify -->
  <script src="EspruinoTools/libs/esprima/escodegen.js"></script> <!-- needed for minify -->
  <script src="EspruinoTools/plugins/minify.js"></script>

  <script src="js/plugins/fontSize.js"></script>
  <script src="js/plugins/uiMode.js"></script>
  <script src="js/plugins/urlHandler.js"></script>
  <script src="js/plugins/fileReload.js"></script>

  <!-- <script src="js/plugins/_examplePlugin.js"></script> -->

  <title>Espruino Uploader</title>
</head>
<body>
  <div class="window">

    <!-- Viewport -->
    <div class="window__viewport">
      <!-- Splitter -->
      <div class="full-pane" style="margin-top: 0px;">

          <div class="editor editor--terminal">
            <div class="sidebar editor__sidebar">
              <div class="v-split">
                <div class="v-split__top sidebar__buttons sidebar__buttons--top"></div>
                <div class="v-split__bottom sidebar__buttons sidebar__buttons--bottom"></div>
              </div>
            </div>
            <div class="canvas editor__canvas editor__canvas__terminal"></div>
          </div>

      </div>

      <!-- Status -->
      <div class="status">
        <div class="h-split">
          <div class="h-split__left status__left"></div>
          <div class="h-split__right status__right"></div>
        </div>
      </div>

    </div>

<script>
  var uploadCode;
  if (window.location.search && window.location.search[0]=="?") {
    var querys = window.location.search.substr(1).split("&");
    querys.forEach(function(query) {
      if (query.substr(0,5)=="code=") {
        uploadCode = decodeURIComponent(query.substr(5));
      }
    });
  }
  function sendUploadedCode() {
    Espruino.Core.MenuPortSelector.ensureConnected(function() {
      Espruino.callProcessor("sending");
      Espruino.callProcessor("transformForEspruino", uploadCode, function(code) {
        Espruino.Core.CodeWriter.writeToEspruino(code, function() {
          Espruino.Core.Terminal.addNotification("Uploaded!");
        });
      });
    });
  }

  if (uploadCode) {
    Espruino.Plugins.Uploader = {
      init : function() {
        Espruino.Core.App.addIcon({
          id: "deploy",
          icon: "deploy",
          title : "Send to Espruino",
          order: 400,
          area: {
            name: "terminal",
            position: "top"
          },
          click: sendUploadedCode
        });
        sendUploadedCode();
      }
    }
  }
</script>

</body>
</html>
